<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主要内容区main</title>
<link href="${pageContext.request.contextPath }/css/css.css" type="text/css" rel="stylesheet" />
<link href="${pageContext.request.contextPath }/css/main.css" type="text/css" rel="stylesheet" />
<link rel="shortcut icon" href="${pageContext.request.contextPath }/images/main/favicon.ico" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/css/common.css"/>
<script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/main.js" type="text/javascript"></script>
<style>
body{overflow-x:hidden; background:#f2f0f5; padding:15px 0px 10px 5px;}
#searchmain{ font-size:12px;}
#search{ font-size:12px; background:#548fc9; margin:10px 10px 0 0; display:inline; width:100%; color:#FFF; float:left}
#search form span{height:40px; line-height:40px; padding:0 0px 0 10px; float:left;}
#search form input.text-word{height:24px; line-height:24px; width:180px; margin:8px 0 6px 0; padding:0 0px 0 10px; float:left; border:1px solid #FFF;}
#search form input.text-but{height:24px; line-height:24px; width:55px; background:url(${pageContext.request.contextPath }/images/main/list_input.jpg) no-repeat left top; border:none; cursor:pointer; font-family:"Microsoft YaHei","Tahoma","Arial",'宋体'; color:#666; float:left; margin:8px 0 0 6px; display:inline;}
#search a.add{ background:url(${pageContext.request.contextPath }/images/main/add.jpg) no-repeat -3px 7px #548fc9; padding:0 10px 0 26px; height:40px; line-height:40px; font-size:14px; font-weight:bold; color:#FFF; float:right}
#search a:hover.add{ text-decoration:underline; color:#d2e9ff;}
#main-tab{ border:1px solid #eaeaea; background:#FFF; font-size:12px;}
#main-tab th{ font-size:12px; background:url(${pageContext.request.contextPath }/images/main/list_bg.jpg) repeat-x; height:32px; line-height:32px;}
#main-tab td{ font-size:12px; line-height:40px;}
#main-tab td a{ font-size:12px; color:#548fc9;}
#main-tab td a:hover{color:#565656; text-decoration:underline;}
.bordertop{ border-top:1px solid #ebebeb}
.dialog{ width: 300px; height: 430px; margin: 0 auto; display: none; background-color: #ffffff; position: fixed; top: 30%; left: 50%; margin: -120px 0 0 -150px; z-index: 10000; border: 1px solid #ccc; border-radius: 10px; -webkit-border-radius: 10px; box-shadow: 3px 2px 4px rgba(0,0,0,0.2); -webkit-box-shadow: 3px 2px 4px rgba(0,0,0,0.2); }
.borderright{ border-right:1px solid #ebebeb}
.borderbottom{ border-bottom:1px solid #ebebeb}
.borderleft{ border-left:1px solid #ebebeb}
.gray{ color:#dbdbdb;}
td.fenye{position:fixed; bottom:10px;right:10px;padding:10px 0 0 0; text-align:right;}
.bggray{ background:#f9f9f9}
</style>
</head>
<script type="text/javascript">
//分类管理
function delProduct(id) {
	var url = "${pageContext.request.contextPath}/adproduct?method=delProduct";
	if(confirm("确定要删除此商品？")){
		$.ajax({
			url:url,
			dataType:"json",
			type:"post",
			data:{"pid":id},
			success : function(data) {
				if(data.msg == "200"){
					$("#" + id).remove();
				}
				if(data.msg == "no"){
					alert("此商品还有未完成订单！");
				}
			}
		})
	}
}
</script>
<body>
	<!--main_top-->
<table width="99%" border="0" cellspacing="0" cellpadding="0" id="searchmain">
  <tr>
    <td width="99%" align="left" valign="top">您的位置：已上架商品</td>
  </tr>
  <tr>
    <td align="left" valign="top">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="search">
  		<tr>
   		 <td width="90%" align="left" valign="middle">
         </td>
  		  <td width="10%" align="center" valign="middle" style="text-align:right; width:150px;"><a href="${pageContext.request.contextPath }/adproduct?method=show_Product" target="mainFrame" onFocus="this.blur()" class="add">新增商品</a></td>
  		</tr>
	</table>
    </td>
  </tr>
  <tr>
    <td align="left" valign="top">
    <div class="box">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="main-tab">
      <tr>
        <th align="center" valign="middle" class="borderright">编号</th>
        <th align="center" valign="middle" class="borderright">商品图片</th>
        <th align="center" valign="middle" class="borderright">商品名称</th>
        <th align="center" valign="middle" class="borderright">价格</th>
        <th align="center" valign="middle" class="borderright">是否热门</th>
        <th align="center" valign="middle" class="borderright">是否上架</th>
        <th align="center" valign="middle" class="borderright">上架日期</th>
        <th align="center" valign="middle">操作</th>
      </tr>
      <c:forEach items="${adbean.data  }" var="p">
     
      <tr id="${p.pid }" onMouseOut="this.style.backgroundColor='#ffffff'" onMouseOver="this.style.backgroundColor='#edf5ff'">
        <td align="center" valign="middle" class="borderright borderbottom">${p.pid }</td>
        <td align="center" valign="middle" class="borderright borderbottom">
        <img src="${pageContext.request.contextPath}/${p.pimage }" width="30" height="30"></td>
        <td align="center" valign="middle" class="borderright borderbottom" id="td1_${p.pid }">${p.pname }</td>
        <td align="center" valign="middle" class="borderright borderbottom" id="td2_${p.pid }">${p.shop_price }</td>
        <td align="center" valign="middle" class="borderright borderbottom">
		<c:if test="${p.is_hot == 0 }">否</c:if>
		<c:if test="${p.is_hot == 1 }">是</c:if>
		</td>
        <td align="center" valign="middle" class="borderright borderbottom">
		<c:if test="${p.pflag == 0 }">已上架</c:if>
		<c:if test="${p.pflag == 1 }">已下架</c:if>
		</td>
        <td align="center" valign="middle" class="borderright borderbottom">${p.pdate }</td>
        <td align="center" valign="middle" class="borderbottom"><a href="javascript:adedit('${p.pid }');" target="mainFrame" class="flipInX">编辑</a><span class="gray">&nbsp;|&nbsp;</span><a href="javascript:delProduct('${p.pid }')" target="mainFrame" onFocus="this.blur()" class="add">删除</a></td>
      </tr>
      <div id="dialogBg"></div>
		<div id="dialog_${p.pid }" class="animated dialog">
			<img class="dialogIco" width="50" height="50" src="${pageContext.request.contextPath }/images/ico.png" alt="" />
			<div class="dialogTop">
				<a href="javascript:;" class="claseDialogBtn">关闭</a>
			</div>
			<form method="post" id="editForm" action="${pageContext.request.contextPath }/updateproduct" enctype="multipart/form-data">
				<input type="hidden" name="pageNumber" value="${adbean.pageNumber }">
				<input type="hidden" name="pid" value="${p.pid }">
				<ul class="editInfos">
					<li><label><font color="#ff0000">* </font>商品&emsp;ID：<input  type="text" name="pid" disabled required value="${p.pid }" class="ipt" /></label></li>
					<li><label><font color="#ff0000">* </font>名&emsp;&emsp;称：<input  type="text" name="pname" required value="${p.pname }" class="ipt" /></label></li>
					<li><label><font color="#ff0000">* </font>市&ensp;场&ensp;价：<input  type="text" name="market_price" required value="${p.market_price }" class="ipt" /></label></li>
					<li><label><font color="#ff0000">* </font>售&emsp;&emsp;价：<input type="text" name="shop_price" required value="${p.shop_price }" class="ipt" /></label></li>
					<li><label><font color="#ff0000">* </font>商品详情：<textarea style="vertical-align:top;resize:none;width:175px;height:50px;" name="pdesc">${p.pdesc }</textarea></label></li>
					<li><label><font color="#ff0000">* </font>商品图片：<input type="file" onchange="imgPreview(this)" name="pimage" style="display: none;" id="previewImg"  class="ipt">
					<img id="pic" border="0" src="${p.pimage }"  width="90" height="90">
					</label></li>
					<li><input type="submit" value="确认提交"  class="submitBtn" /></li>
				</ul>
			</form>
		</div>
      </c:forEach>
    </table>
    </div>
    </td>
    </tr>
  <tr>
    <td align="left" valign="top" class="fenye">${adbean.totalRecord } 条数据 &nbsp;&nbsp;第 ${adbean.pageNumber } 页&nbsp;&nbsp;
    <!-- 首页 -->
    <c:if test="${adbean.pageNumber == 1 }">
   		 <a href="javascript:void();" target="mainFrame" onFocus="this.blur()">首页</a>&nbsp;&nbsp;
    </c:if>
    <c:if test="${adbean.pageNumber != 1 }">
   		 <a href="${pageContext.request.contextPath}/adproduct?method=findByAdPage&pageNumber=1" target="mainFrame" onFocus="this.blur()">首页</a>&nbsp;&nbsp;
    </c:if>
    
    <!-- 上一页 -->
    <c:if test="${adbean.pageNumber == 1 }">
    	<a href="javascript:void();" target="mainFrame" onFocus="this.blur()">上一页</a>&nbsp;&nbsp;
    </c:if>
   	<c:if test="${adbean.pageNumber != 1 }">
   		 <a href="${pageContext.request.contextPath}/adproduct?method=findByAdPage&pageNumber=${adbean.pageNumber - 1}" target="mainFrame" onFocus="this.blur()">上一页</a>&nbsp;&nbsp;
    </c:if>
    
     <!-- 下一页 --> <!-- 尾页 -->
     <c:if test="${adbean.pageNumber == adbean.totalPage }">
   		 <a href="javascript:void();" target="mainFrame" onFocus="this.blur()">下一页</a>&nbsp;&nbsp;
     	 <a href="javascript:void();" target="mainFrame" onFocus="this.blur()">尾页</a>
     </c:if>
     <c:if test="${adbean.pageNumber != adbean.totalPage }">
   		 <a href="${pageContext.request.contextPath}/adproduct?method=findByAdPage&pageNumber=${adbean.pageNumber + 1}" target="mainFrame" onFocus="this.blur()">下一页</a>&nbsp;&nbsp;
     	 <a href="${pageContext.request.contextPath}/adproduct?method=findByAdPage&pageNumber=${adbean.totalPage }" target="mainFrame" onFocus="this.blur()">尾页</a>
     </c:if>
     
    
    </td>
    
  </tr>
</table>
</body>
</html>